package com.navinfo.tripanalysis.pojo;

import com.github.yt.excel.annotations.ExportExcel;
import com.github.yt.excel.annotations.ImportExcel;
import lombok.Data;
import org.apache.spark.sql.types.DataTypes;
import org.apache.spark.sql.types.Metadata;
import org.apache.spark.sql.types.StructField;
import org.apache.spark.sql.types.StructType;

import java.util.ArrayList;
import java.util.List;


/**
 * 0200的pojo<br/>
 * 和公共轨迹协议的pojo相同<br/>
 * @author web
 **/
@Data
public class Point0200 implements Point {
    /**
     * tripId,行程ID（公共）
     */
    @ExportExcel(title = "tripId", order = 0)
    @ImportExcel(order = 0)
    private int tripId;

    /**
     * tid,（公共）
     */
    @ExportExcel(title = "tid", order = 1)
    @ImportExcel(order = 1)
    private long tid;
    /**
     *  协议类型,1:0f37,2:0200（公共）
     */
    @ExportExcel(title = "protocol", order = 2)
    @ImportExcel(order = 2)
    private byte protocol;

    /**
     * gps时间，单位毫秒（公共）
     */
    @ExportExcel(title = "gpsTime", order = 3)
    @ImportExcel(order = 3)
    private long gpsTime;
    /**
     * 车速,单位km/h，(公共)
     */
    @ExportExcel(title = "speed", order = 4)
    @ImportExcel(order = 4)
    private double speedKmh;

    /**
     * 纬度，单位度，扩展10的6次方(公共)
     */
    @ExportExcel(title = "latitude", order = 5)
    @ImportExcel(order = 5)
    private int latitude;

    /**
     * 经度，单位度，扩展10的6次方(公共)
     */
    @ExportExcel(title = "longitude", order = 6)
    @ImportExcel(order = 6)
    private int longitude;

    /**
     * 方向(0~359)正北为0，顺时针(公共)
     */
    @ExportExcel(title = "direction", order = 7)
    @ImportExcel(order = 7)
    private int direction;

    /**
     * 高程，海拔高度，单位m (公共)
     */
    @ExportExcel(title = "height", order = 8)
    @ImportExcel(order = 8)
    private double height;

    /**
     * 发动机输出扭矩，单位%，(公共)
     */
    @ExportExcel(title = "torque", order = 9)
    @ImportExcel(order = 9)
    private int engineOutputTorque;

    /**
     * 发动机转速，单位rpm转每分钟，(公共)
     */
    @ExportExcel(title = "rotation", order = 10)
    @ImportExcel(order = 10)
    private int rotation;

    /**
     * 油门开度百分比，单位%，(公共)
     */
    @ExportExcel(title = "accelerator", order = 11)
    @ImportExcel(order = 11)
    private int accPedalPos;

    /**
     * 制动信号状态，0关，1开（0F37特有）
     */
    @ExportExcel(title = "brake", order = 12)
    @ImportExcel(order = 12)
    private int brake;

    /**
     * 离合开关状态，0关，1开(公共)
     */
    @ExportExcel(title = "clutchSwitch", order = 13)
    @ImportExcel(order = 13)
    private int clutchSwitch;

    /**
     * 发动机瞬时油耗，单位KM/L (公共)
     */
    @ExportExcel(title = "realTimeFuelConsumption", order = 14)
    @ImportExcel(order = 14)
    private double realTimeOilConsumption;

    /**
     * 发动机燃油消耗率，单位L/H (公共)
     */
    @ExportExcel(title = "fuelConsumptionRate", order = 15)
    @ImportExcel(order = 15)
    private double fuelConsumptionRate;

    /**
     *  大气温度,单位：摄氏度（0F37特有）
     */
    @ExportExcel(title = "atmosphericTem", order = 16)
    @ImportExcel(order = 16)
    private int atmosphericTem;

    /**
     * acc状态，0关，1开（0200特有）
     */
    @ExportExcel(title = "acc状态", order = 17)
    @ImportExcel(order = 17)
    private int accStatus;

    /**
     * GPS里程，单位KM（0200特有）
     */
    @ExportExcel(title = "gps里程", order = 18)
    @ImportExcel(order = 18)
    private double gpsMileage;

    /**
     * can、ecu里程，单位KM（0200特有）
     */
    @ExportExcel(title = "ecu里程", order = 19)
    @ImportExcel(order = 19)
    private double ecuMileage;

    /**
     * 仪表里程，单位KM（0200特有）
     */
    @ExportExcel(title = "仪表里程", order = 20)
    @ImportExcel(order = 20)
    private double meterMileage;

    /**
     * 积分里程，单位KM（0200特有），不使用
     */
    @ExportExcel(title = "积分里程", order = 21)
    @ImportExcel(order = 21)
    private double integralMileage;

    /**
     * 标准总里程，单位KM（0200特有）
     */
    @ExportExcel(title = "标准总里程", order = 22)
    @ImportExcel(order = 22)
    private float standardMileage;

    /**
     * 积分油耗，单位L（0200特有）
     */
    @ExportExcel(title = "积分油耗", order = 23)
    @ImportExcel(order = 23)
    private double integralFuelCons;

    /**
     *燃油总消耗，单位L（0200特有）
     */
    @ExportExcel(title = "燃油总消耗", order = 24)
    @ImportExcel(order = 24)
    private double totalFuelCons;

    /**
     * 标准总油耗，单位L（0200特有）
     */
    @ExportExcel(title = "标准总油耗", order = 25)
    @ImportExcel(order = 25 )
    private float standardFuelCons;

    /**
     * 冷却水温（0200特有）
     */
    @ExportExcel(title = "冷却水温", order = 26)
    @ImportExcel(order = 26)
    private int coolingWaterTem;

    /**
     * 进气温度（0200特有）
     */
    @ExportExcel(title = "进气温度", order = 27)
    @ImportExcel(order = 27)
    private int intakeAirTem;

    /**
     * 进气压力（0200特有）
     */
    @ExportExcel(title = "进气压力", order = 28)
    @ImportExcel(order = 28)
    private int intakePressure;

    /**
     * 定速巡航状态，0关，1开（0200特有）
     */
    @ExportExcel(title = "定速巡航", order = 29)
    @ImportExcel(order = 29)
    private boolean cruiseControl;

    /**
     * 油液百分比，（0200特有）
     */
    @ExportExcel(title = "油液百分比", order = 30)
    @ImportExcel(order = 30)
    private double oilPercentage;

    /**
     * 手刹状态，0关，1开（0200特有）
     */
    @ExportExcel(title = "手刹状态", order = 31)
    @ImportExcel(order = 31)
    private int handBrakeStatus;

    /**
     * 空挡滑行状态，0:不是，1:空挡滑行（0200特有）
     */
    @ExportExcel(title = "空挡滑行状态", order = 32)
    @ImportExcel(order = 32)
    private int slideNeutralStatus;

    /**
     *急加速状态，0：不是，1：急加速（0200特有）
     */
    @ExportExcel(title = "急加速状态", order = 33)
    @ImportExcel(order = 33)
    private int rapidAccelerationStatus;

    /**
     * 急减速状态，0：不是，1：急减速（0200特有）
     */
    @ExportExcel(title = "急减速状态", order = 34)
    @ImportExcel(order = 34)
    private int rapidDecelerationStatus;

    /**
     * 急转弯状态，0：不是，1：急转弯（0200特有）
     */
    @ExportExcel(title = "急转弯状态", order = 35)
    @ImportExcel(order = 35)
    private int sharpTurningStatus;

    /**
     * 猛踩油门状态，0：不是，1：猛踩油门（0200特有）
     */
    @ExportExcel(title = "猛踩油门状态", order =36 )
    @ImportExcel(order = 36)
    private int slamAcceleratorStatus;

    /**
     * AMT载重,单位kg（0200特有）
     */
    @ExportExcel(title = "AMT载重", order =37 )
    @ImportExcel(order = 37)
    private int amtLoad;
    /**
     * VECU载重,单位kg（0200特有）
     */
    @ExportExcel(title = "VECU载重", order =38 )
    @ImportExcel(order = 38)
    private int vecuLoad;

    /**
     * 是否补传，0不是，1是（0200特有）
     */
    @ExportExcel(title = "补传标识", order = 39)
    @ImportExcel(order = 39)
    private boolean patch;

    /**
     * 流水号（0200特有,0F37为0）
     */
    @ExportExcel(title = "流水号", order = 40)
    @ImportExcel(order =40 )
    private int serialNumber;
    /**
     * 仪表车速（0F37特有）
     */
    @ExportExcel(title = "仪表车速", order = 41)
    @ImportExcel(order =41 )
    private double instrumentSpeed;

    /**
     *  尿素喷射量,单位:克（0F37特有）
     */
    @ExportExcel(title = "尿素消耗", order = 42)
    @ImportExcel(order = 42)
    private int ureaInjection;

    /**
     *  尿素液位,单位:%
     */
    @ExportExcel(title = "urealevel", order = 43)
    @ImportExcel(order = 43)
    private int ureaLevel;

//    @Override
//    public int getUreaInjection() {
//        return 0;
//    }


    /**
     * 创建公共轨迹协议的schema
     * @return
     */
    public static StructType createSchema() {
        List<StructField> list = new ArrayList<>();
        list.add(new StructField("tid", DataTypes.StringType, true, Metadata.empty()));
        list.add(new StructField("tripId", DataTypes.StringType, true, Metadata.empty()));
        list.add(new StructField("protocol", DataTypes.StringType, true, Metadata.empty()));
        list.add(new StructField("gpsTime", DataTypes.StringType, true, Metadata.empty()));
        list.add(new StructField("speed", DataTypes.StringType, true, Metadata.empty()));
        list.add(new StructField("latitude", DataTypes.StringType, true, Metadata.empty()));
        list.add(new StructField("longitude", DataTypes.StringType, true, Metadata.empty()));
        list.add(new StructField("direction", DataTypes.StringType, true, Metadata.empty()));
        list.add(new StructField("height", DataTypes.StringType, true, Metadata.empty()));
        list.add(new StructField("torque", DataTypes.StringType, true, Metadata.empty()));
        list.add(new StructField("rotation", DataTypes.StringType, true, Metadata.empty()));
        list.add(new StructField("accelerator", DataTypes.StringType, true, Metadata.empty()));
        list.add(new StructField("brake", DataTypes.StringType, true, Metadata.empty()));
        list.add(new StructField("clutchSwitch", DataTypes.StringType, true, Metadata.empty()));
        list.add(new StructField("realtimeFuelConsumption", DataTypes.StringType, true, Metadata.empty()));
        list.add(new StructField("fuelConsumptionRate", DataTypes.StringType, true, Metadata.empty()));
        list.add(new StructField("atmosphericTem", DataTypes.StringType, true, Metadata.empty()));
        list.add(new StructField("accStatus", DataTypes.StringType, true, Metadata.empty()));
        list.add(new StructField("gpsMileage", DataTypes.StringType, true, Metadata.empty()));
        list.add(new StructField("ecuMileage", DataTypes.StringType, true, Metadata.empty()));
        list.add(new StructField("meterMileage", DataTypes.StringType, true, Metadata.empty()));
        list.add(new StructField("integralMileage", DataTypes.StringType, true, Metadata.empty()));
        list.add(new StructField("standardMileage", DataTypes.StringType, true, Metadata.empty()));
        list.add(new StructField("integralFuelCons", DataTypes.StringType, true, Metadata.empty()));
        list.add(new StructField("totalFuelCons", DataTypes.StringType, true, Metadata.empty()));
        list.add(new StructField("standardFuelCons", DataTypes.StringType, true, Metadata.empty()));
        list.add(new StructField("coolingWaterTem", DataTypes.StringType, true, Metadata.empty()));
        list.add(new StructField("intakeAirTem", DataTypes.StringType, true, Metadata.empty()));
        list.add(new StructField("intakePressure", DataTypes.StringType, true, Metadata.empty()));
        list.add(new StructField("cruiseControl", DataTypes.StringType, true, Metadata.empty()));
        list.add(new StructField("oilPercentage", DataTypes.StringType, true, Metadata.empty()));
        list.add(new StructField("handBrakeStatus", DataTypes.StringType, true, Metadata.empty()));
        list.add(new StructField("slideNeutralStatus", DataTypes.StringType, true, Metadata.empty()));
        list.add(new StructField("rapidAccelerationStatus", DataTypes.StringType, true, Metadata.empty()));
        list.add(new StructField("rapidDecelerationStatus", DataTypes.StringType, true, Metadata.empty()));
        list.add(new StructField("sharpTurningStatus", DataTypes.StringType, true, Metadata.empty()));
        list.add(new StructField("slamAcceleratorStatus", DataTypes.StringType, true, Metadata.empty()));
        list.add(new StructField("amtLoad", DataTypes.StringType, true, Metadata.empty()));
        list.add(new StructField("vecuLoad", DataTypes.StringType, true, Metadata.empty()));
        list.add(new StructField("isPatch", DataTypes.StringType, true, Metadata.empty()));
        list.add(new StructField("serialNumber", DataTypes.StringType, true, Metadata.empty()));
        list.add(new StructField("instrumentSpeed", DataTypes.StringType, true, Metadata.empty()));
        list.add(new StructField("ureaInjection", DataTypes.StringType, true, Metadata.empty()));
        list.add(new StructField("ureaLevel", DataTypes.StringType, true, Metadata.empty()));

        return new StructType(list.toArray(new StructField[list.size()]));
    }


}
